home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJ111M3.ZIP / include / ctype.h next >
C/C++ Source or Header  |  1994-02-05  |  2KB  |  76 lines

  1. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  2. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  3. ** Rochester NH, 03867-2954, USA.
  4. */
  5.  
  6. /*
  7.  Here's a ctype.h for SunOS-3 and vax 4.3BSD.  
  8.  It will probably work on most BSD derived systems. 
  9.  Just compare it to the C version to verify.
  10.  No big deal, but it will save you some typing.
  11. */
  12.    
  13. #ifndef _ctype_h
  14. #define _ctype_h
  15.  
  16. #include <stdio.h>  /* sorry, but needed for USG stuff */
  17.    
  18. #define _U 01
  19. #define _L 02
  20. #define _N 04
  21. #define _S 010
  22. #define _P 020
  23. #define _C 040
  24.  
  25.  
  26. #if defined(USG) || defined(DGUX)
  27. #define _B 0100 /* different from BSD */
  28. #define _X 0200 /* different from BSD */
  29. #else
  30. #define _X 0100
  31. #define _B 0200
  32. #endif
  33.  
  34.  
  35. #ifdef DGUX
  36. #define CTYPE_TYPE      short
  37. #else
  38. #define CTYPE_TYPE      char
  39. #endif
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. extern  CTYPE_TYPE      _ctype_[];
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48.    
  49. #define isalpha(c)  ((_ctype_+1)[c]&(_U|_L))
  50. #define isupper(c)  ((_ctype_+1)[c]&_U)
  51. #define islower(c)  ((_ctype_+1)[c]&_L)
  52. #define isdigit(c)  ((_ctype_+1)[c]&_N)
  53. #define isxdigit(c) ((_ctype_+1)[c]&(_X|_N))
  54. #define isspace(c)  ((_ctype_+1)[c]&_S)
  55. #define ispunct(c)  ((_ctype_+1)[c]&_P)
  56. #define isalnum(c)  ((_ctype_+1)[c]&(_U|_L|_N))
  57. #define isprint(c)  ((_ctype_+1)[c]&(_P|_U|_L|_N|_B))
  58. #define isgraph(c)  ((_ctype_+1)[c]&(_P|_U|_L|_N))
  59. #define iscntrl(c)  ((_ctype_+1)[c]&_C)
  60. #define isascii(c)  ((unsigned)(c)<=0177)
  61.  
  62. #define toupper(c)  ({int _c=(c); islower(_c) ? (_c-'a'+'A') : _c; })
  63. #define tolower(c)  ({int _c=(c); isupper(_c) ? (_c-'A'+'a') : _c; })
  64. #define toascii(c)  ((c)&0177)
  65.  
  66.  
  67. #ifdef _ctype_
  68. #undef _ctype_
  69. #endif
  70.  
  71. #ifdef CTYPE_TYPE
  72. #undef CTYPE_TYPE
  73. #endif
  74.  
  75. #endif /* _ctype_h */
  76.